package com.zhentao.controller;

import com.zhentao.common.constants.ArticleConstants;
import com.zhentao.model.article.dto.ArticleHomeDto;
import com.zhentao.model.article.dto.ArticleInfoDto;
import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.service.ArticleService;
import com.zhentao.service.HotArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/article")
public class ApArticleHomeController {
    @Autowired
    private ArticleService articleService;

    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleHomeDto dto){
//        return articleService.load(0,dto);
        return articleService.load2(dto, 0,true);
    }


    @PostMapping("/loadmore")
    public ResponseResult loadmore(@RequestBody ArticleHomeDto dto){
        return articleService.load(1,dto);
    }

    @PostMapping("/loadnew")
    public ResponseResult loadnew(@RequestBody ArticleHomeDto dto){
        return articleService.load(2,dto);
    }

    @PostMapping("load_article_behavior")
    public ResponseResult loadArticleBehavior(@RequestBody ArticleInfoDto dto){
        return articleService.loadArticleBehavior(dto);
    }
    @Autowired
    private HotArticleService hotArticleService;

    @GetMapping("testHot")
    public ResponseResult testHot(){
        hotArticleService.computeHotArticle();;
        return ResponseResult.okResult("成功");
    }
}
